import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Home from '../views/Home.vue';
import HomeHr from '../views/HomeHr.vue';
import HomeSystem from '../views/HomeSystem.vue';
import HomeAbout from '../views/HomeAbout.vue';
import HomeLogin from '../views/HomeLogin.vue';
import HomeRegister from '../views/HomeRegister.vue';
// 二级路由
import SystemSettingsOrgn from '@/views/system/SystemSettingsOrgn.vue';
import SystemSettingsMgroup from '@/views/system/SystemSettingsMgroup.vue';
import Contact from '../views/about/Contact.vue';
import Delivery from '../views/about/Delivery.vue';
import History from '../views/about/History.vue';
import OrderingGuide from '../views/about/OrderingGuide.vue';
// 三级路由
import Phone from '../views/about/contact/Phone.vue';
import PersonName from '../views/about/contact/PersonName.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: '首页',
    component: Home,
    children: [
      { path: '/hr', name: '人力资源管理', component: HomeHr },
      {
        path: '/system',
        name: '系统管理',
        component: HomeSystem,
        children: [
          { path: '/system/settings/orgn', name: '公司管理', component: SystemSettingsOrgn },
          { path: '/system/settings/mgroup', name: '权限组管理', component: SystemSettingsMgroup }
        ]
      },
      {
        path: '/about',
        name: '关于我们',
        component: HomeAbout,
        redirect: '/about/contact',
        children: [
          {
            path: '/about/contact',
            name: 'contactLink',
            redirect: '/about/contact/personname',
            component: Contact,
            children: [
              { path: '/about/contact/phone', name: 'phoneNumber', component: Phone },
              { path: '/about/contact/personname', name: 'personName', component: PersonName }
            ]
          },
          { path: '/about/delivery', name: 'deliveryLink', component: Delivery },
          { path: '/about/history', name: 'historyLink', component: History },
          { path: '/about/orderingGuide', name: 'orderingGuideLink', component: OrderingGuide },
          { path: '/about/orgn', name: 'orgnLink', component: SystemSettingsOrgn }
        ]
      },
      { path: '/login', name: 'loginLink', component: HomeLogin },
      { path: '/register', name: 'registerLink', component: HomeRegister }
    ]
  }
  // ,
  // { path: '*', redirect: '/' }
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
});

export default router;
